namespace dPet.Infrastructure.EntityFramework.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class AddModels1 : DbMigration
    {
        public override void Up()
        {
            RenameTable(name: "dbo.SaleOrderBillTemplate", newName: "BillTemplate");
            CreateTable(
                "dbo.ServiceOrder",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 32),
                        MembershipLevel = c.Int(nullable: false),
                        PaymentMethod = c.Int(nullable: false),
                        OrderNumber = c.String(nullable: false, maxLength: 32),
                        HospitalId = c.String(nullable: false, maxLength: 32),
                        Status = c.Int(nullable: false),
                        Creator = c.String(maxLength: 50),
                        CreateTime = c.DateTime(nullable: false),
                        Completer = c.String(maxLength: 50),
                        CompleteTime = c.DateTime(nullable: false),
                        TotalAmount = c.Decimal(nullable: false, precision: 18, scale: 2),
                        LastModified = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.ServiceOrderLine",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 32),
                        ServiceItemName = c.String(nullable: false, maxLength: 50),
                        SKUPropertyValueNames = c.String(),
                        UnitPrice = c.Decimal(nullable: false, precision: 18, scale: 2),
                        Quantity = c.Int(nullable: false),
                        LastModified = c.DateTime(nullable: false),
                        ServiceOrder_Id = c.String(nullable: false, maxLength: 32),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ServiceOrder", t => t.ServiceOrder_Id, cascadeDelete: true)
                .Index(t => t.ServiceOrder_Id);
            
            AddColumn("dbo.ServiceItemSKU", "UnitPrice", c => c.Decimal(nullable: false, precision: 18, scale: 2));
            DropColumn("dbo.ServiceItemSKU", "Price");
        }
        
        public override void Down()
        {
            AddColumn("dbo.ServiceItemSKU", "Price", c => c.Decimal(nullable: false, precision: 18, scale: 2));
            DropForeignKey("dbo.ServiceOrderLine", "ServiceOrder_Id", "dbo.ServiceOrder");
            DropIndex("dbo.ServiceOrderLine", new[] { "ServiceOrder_Id" });
            DropColumn("dbo.ServiceItemSKU", "UnitPrice");
            DropTable("dbo.ServiceOrderLine");
            DropTable("dbo.ServiceOrder");
            RenameTable(name: "dbo.BillTemplate", newName: "SaleOrderBillTemplate");
        }
    }
}
